package kuang.juc.lock8;

import java.util.concurrent.TimeUnit;


public class Test6 {
    public static void main(String[] args) {

        new Thread(Phone6::sedMsg,"A").start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(Phone6::call,"B").start();
    }
}

/**
 * synchronized锁类的调用者
 * 此时静态方法sedMsg是class模版锁，call无锁
 * 先打电话，后发短信
 */
class Phone6{
    public static synchronized void sedMsg() {
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("发短信");
    }

    public static void call(){
        System.out.println("打电话");
    }
}
